// Copyright [2020] <unknown>
#include <bits/stdc++.h>
using namespace std;
// #define ONLINE_JUDGE
#ifndef ONLINE_JUDGE
#define dbg(x...) { cerr << "\033[32;1m" << #x << " -> "; err(x); }
void err() { cerr << "\033[39;0m" << endl; }
template<typename T, typename... A>
void err(T a, A... x) { cerr << a << ' '; err(x...); }
#else
#define dbg(...)
#endif

#define sz(x) ((int)x.size())

typedef long long LL;

int t, n;

int x, y;

const int N = 1e7+50;

LL a[N];

set<pair<LL, LL>> S;
set<LL> ans;

int main(int argc, char const *argv[]) {
    // scanf("%d%d", &a[0], &a[1]);
    cin >> a[0] >> a[1];
    ans.insert(a[0]);
    ans.insert(a[1]);
    S.insert(make_pair(a[0], a[1]));
    for (int i=2; i<N; ++i) {
        a[i] = llabs(a[i-1] - a[i-2]);
        if (S.count(make_pair(a[i], a[i-1]))) {
            dbg(i, a[i-1], a[i-2]);
            break;
        }
        ans.insert(a[i]);
        S.insert(make_pair(a[i], a[i-1]));
    }
    cout << ans.size() << endl;
    for (int i=0; i<20; ++i)
        dbg(i, a[i]);
    return 0;
}
